//
//  AllcommendModel.m
//  u76ho
//
//  Created by m-air-01 on 16/1/24.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "AllcommendModel.h"

@implementation AllcommendModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqualToString:@"errmsg"]) {
        
        NSDictionary * dic = value;
        NSArray * keyArr = [dic allKeys];
        
        if ([keyArr containsObject:@"a"]) {
            NSArray * arr = [dic objectForKey:@"a"];
            NSDictionary * dic = arr.firstObject;
            AllCommendBaseInfoModel * model = [[AllCommendBaseInfoModel alloc]initDic:dic];
            _baseInfomodel = model;
        }
        
        if ([keyArr containsObject:@"b"]) {
            NSArray * arr = [dic objectForKey:@"b"];
            NSMutableArray * mArr = [[NSMutableArray alloc]init];
            for (int i = 0; i<arr.count; i++) {
                NSDictionary * dic = arr[i];
                AllCommendInfoModel * model = [[AllCommendInfoModel alloc]initDic:dic];
                [mArr addObject:model];
            }
            _commendContentArr = mArr;
        }
        
        if ([keyArr containsObject:@"c"]) {
            NSArray * arr = [dic objectForKey:@"c"];
            NSMutableArray * mArr = [[NSMutableArray alloc]init];
            for (int i = 0; i<arr.count; i++) {
                NSDictionary * dic = arr[i];
                AllZanModel * model = [[AllZanModel alloc]initDic:dic];
                [mArr addObject:model];
            }
            _zanArr = mArr;
        }
        
        
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end

//*****************************************
@implementation AllCommendBaseInfoModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        [super setValue:value forKey:key];
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end

//*****************************************
@implementation AllCommendInfoModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        [super setValue:value forKey:key];
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end

//*********************************************
@implementation AllZanModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        [super setValue:value forKey:key];
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end
